package Effects

import (
	. "GameLogic/Scene/Unit"
	xml "misc/dom4g"
	"strconv"
)

type EffectDamage struct {
	EffectInfo
	DamageNumber int
}

func CreateEffectDamage(xmlnode *xml.Element) IEffect {
	effect := &EffectDamage{}
	effect.EffectInfo.Parse(xmlnode)
	strDamageNumber, _ := xmlnode.AttrValue("DamageNumber")
	effect.DamageNumber, _ = strconv.Atoi(strDamageNumber)
	return effect
}

func (this *EffectDamage) Exec() {
	this.DstUnit.(*Unit).SetHP(this.DstUnit.(*Unit).HP - this.DamageNumber)
}

func (this *EffectDamage) GetBaseInfo() *EffectInfo {
	return &this.EffectInfo
}
